import {
  queryLogLogin, queryLogOperation
} from '@/services/log';

export default {
  namespace: 'log',

  state: {
    dataLogLogin: {
      list: [],
      pagination: {},
    },
    dataLogOperation: {
      list: [],
      pagination: {},
    },
  },

  effects: {
    *fetchLogLogin({ payload }, { call, put }) {
      const response = yield call(queryLogLogin, payload);
      if (response && response.code === 200) {
        yield put({
          type: 'save',
          payload: {
            dataLogLogin: response.data,
          },
        });
      }
    },
    *fetchLogOperation({ payload }, { call, put }) {
      const response = yield call(queryLogOperation, payload);
      if (response && response.code === 200) {
        yield put({
          type: 'save',
          payload: {
            dataLogOperation: response.data,
          },
        });
      }
    },
  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};